import requests
import json

token = "mNCN6rlhuj9JmlSKhVTktiK34X4T3wVDe5zGa3WwHHCjuLyaa1l8zFlO48PYTzHd07CiWHtMtsanQQ_OhDE4vMTIwxZAxvE301KadPjTL9gcvLiR35m0WYYLvIww3Nh_EpHkpl4UtfzjFryq1ka4IeaGQLcMbyPWYbiKVo1eRlm4sB5GOboCuwLcrB31NsAO2t6R3g0yM4IqPlt6sTLunw"
# url = "https://qyapi.weixin.qq.com/cgi-bin/department/create?access_token={}".format(token)
json_data = {"name": "广州研发中心", "parentid": 1}

# rep = requests.post(url=url, json=json_data)
# print(rep.json())

url = "https://qyapi.weixin.qq.com/cgi-bin/department/create"
params = {"access_token": token}

# json传参
# rep = requests.post(url=url, params=params, json=json_data)
# print(rep.json())

# data传参
header = {
    "content-type": "application/json"  # 声明参数格式json
}
print(type(json.dumps(json_data)))
print(json.dumps(json_data))
rep = requests.post(url=url, params=params, headers=header, data=json.dumps(json_data))
print(rep.json())